*****load the data file titled rep_data_August2023.dta
use rep_data_August2023
****************************************************************************
*********************************APPENDIX TABLE AND FIGURES*******************



***************Section A3 Coding for the key variables***********

******Table A2: Existence of written script, linguistic diversity and language policy at independence: OLS Regressions
reg LP_any_colonial1a script_lnnlang  ln_lang Script_N rootstuber_suitabilty cereal_suitabilty  AsiaNew AmericaN colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using olsindp.tex, stats(coef se ) auto(2)   paren(se) bracket (ci) level(95) label replace


reg LP_any_indigenous1a script_lnnlang  ln_lang Script_N rootstuber_suitabilty cereal_suitabilty AsiaNew AmericaN  colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using olsindp.tex, stats(coef se ) auto(2)  paren(se) bracket (ci) level(95) label append


******Table A3: Existence of written script, linguistic diversity and current language policy: OLS Regressions
reg LP_any_colonial2a script_lnnlang  ln_lang Script_N rootstuber_suitabilty cereal_suitabilty  AsiaNew AmericaN colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using olsicurr.tex, stats(coef se ) auto(2)   paren(se) bracket (ci) level(95) label replace


reg LP_any_indigenous2a script_lnnlang  ln_lang Script_N rootstuber_suitabilty cereal_suitabilty AsiaNew AmericaN  colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using olsicurr.tex, stats(coef se ) auto(2)  paren(se) bracket (ci) level(95) label append
**********************************************************************

***********Section A4 - Explanatory power of the two factors: Written script and Linguistic diversity************

*****Table A4: Existence of written script, linguistic diversity and language policy: OLS Regressions

reg LP_any_colonial script_lnnlang  ln_lang Script_N if sampledef==1 , robust 
outreg2 using olsnc.tex, stats(coef se ) auto(2)   paren(se) bracket (ci) level(95) label replace


reg LP_any_indigenous script_lnnlang  ln_lang Script_N if sampledef==1 , robust 
outreg2 using olsnc.tex, stats(coef se ) auto(2)  paren(se) bracket (ci) level(95) label append
*******************************************************

***********Section A5 - Using alternative measures of linguistic diversity******************

*****Table A5: Existence of written script, linguistic diversity and language policy:OLS Regressions using Soviet Atlas data as the measure of linguistic diversity
reg LP_any_colonial script_elfsoviet ethfrac Script_N rootstuber_suitabilty cereal_suitabilty  AsiaNew AmericaN colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using ols2.tex, stats(coef se ) auto(2)   paren(se) bracket (ci) level(95) label replace


reg LP_any_indigenous script_elfsoviet ethfrac Script_N rootstuber_suitabilty cereal_suitabilty AsiaNew AmericaN  colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2  if sampledef==1 , robust 
outreg2 using ols2.tex, stats(coef se ) auto(2)  paren(se) bracket (ci) level(95) label append

***Table A6: Existence of written script, linguistic diversity and language policy: OLS Regressions using linguistic fractionalization data from Alesina et al. (2003)

reg LP_any_colonial ld_script lang_fragm  Script_N rootstuber_suitabilty cereal_suitabilty  AsiaNew AmericaN colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm Npmispc23x10k japn_occupied_ww2 if sampledef==1 , robust 
outreg2 using ols3.tex, stats(coef se ) auto(2)   paren(se) bracket (ci) level(95) label replace


reg LP_any_indigenous ld_script lang_fragm  Script_N rootstuber_suitabilty cereal_suitabilty AsiaNew AmericaN  colony_gbr colony_fra colony_prt rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  Npmispc23x10k japn_occupied_ww2  if sampledef==1 , robust 
outreg2 using ols3.tex, stats(coef se ) auto(2)  paren(se) bracket (ci) level(95) label append
*************************************************


***********Section A6 Distance from sites of writing, written script and official language choice

****Table A7: Distance from sites of invention of writing and existence of a written script for an indigenous language
bysort Dist_Min_MMC_lessMedian1: tab  Litb4mis if sampledef==1 & ln_Dist_Min_MMC>1 & cereal_suitabilty!=. & rootstuber_suitabilty!=.


***Figure A1: Distance from sites of writing and written script for an indigenous language: Partial correlation plot

reg Litb4mis ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty if sampledef==1 & ln_Dist_Min_MMC>1
avplot ln_Dist_Min_MMC, mlabel(pwtcountry) mcolor(black) mlabcolor(black) ytitle("e(Written script|X)") xtitle("e(Log distance sites of writing|X)") ylabel(, nogrid) bgcolor(white) graphregion(color(white))  saving(distrit, replace)
graph export distrit.pdf, replace



****Table A8: Determinants of written script before colonial or missionary contact
**********PANEL A

eststo clear
local outcome Litb4mis  

foreach var of varlist `outcome' {

probit `var' ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty if sampledef==1 & ln_Dist_Min_MMC>1
eststo

probit `var' ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty AsiaNew AmericaN if sampledef==1 & ln_Dist_Min_MMC>1
eststo

probit `var' ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty yst AsiaNew AmericaN if sampledef==1 & ln_Dist_Min_MMC>1
eststo


probit `var' ln_Dist_Min_MMC  cereal_suitabilty rootstuber_suitabilty  AsiaNew AmericaN rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm if sampledef==1 & ln_Dist_Min_MMC>1
eststo

probit `var' ln_Dist_Min_MMC  cereal_suitabilty rootstuber_suitabilty AsiaNew AmericaN if biogeography~=. &  sampledef==1 & ln_Dist_Min_MMC>1
eststo

probit `var' ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty  AsiaNew AmericaN biogeography if biogeography~=. & sampledef==1 & ln_Dist_Min_MMC>1
eststo
}	 
esttab using "Determinants_Lang_Probit", title("Determinants of Written Script before Contact with Christian Missionaries") ///
varwidth(32) replace booktabs  label ///
stats(r2 N,  labels ("R-squared" "Observations"))  scalars(r2 chi2 p ) ///
star (* 0.10 ** 0.05 *** 0.01) width(1.0\hsize)  

**********PANEL B
sum ln_Dist_Min_MMC if ln_Dist_Min_MMC!=. & cereal_suitabilty!=. & rootstuber_suitabilty!=. &  ln_Dist_Min_MMC>1, detail

probit Litb4mis ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty if sampledef==1 &  ln_Dist_Min_MMC>1

margins, at(ln_Dist_Min_MMC=(7.69 8.60))  post

outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  replace ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)

probit Litb4mis ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty  AsiaNew AmericaN if sampledef==1 &  ln_Dist_Min_MMC>1

margins, at(ln_Dist_Min_MMC=(7.69 8.60))  post

outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


probit Litb4mis ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty  yst AsiaNew AmericaN if sampledef==1 &  ln_Dist_Min_MMC>1

margins, at(ln_Dist_Min_MMC=(7.69 8.60))  post

outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


probit Litb4mis ln_Dist_Min_MMC  cereal_suitabilty rootstuber_suitabilty AsiaNew AmericaN  rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm if sampledef==1 &  ln_Dist_Min_MMC>1

margins, at(ln_Dist_Min_MMC=(7.69 8.60))  post

outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


probit Litb4mis ln_Dist_Min_MMC  cereal_suitabilty rootstuber_suitabilty AsiaNew AmericaN if biogeography~=. &  sampledef==1 &  ln_Dist_Min_MMC>1
outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


margins, at(ln_Dist_Min_MMC=(7.69 8.60))  post

outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


probit Litb4mis ln_Dist_Min_MMC cereal_suitabilty rootstuber_suitabilty AsiaNew AmericaN biogeography   if biogeography~=. & sampledef==1 &  ln_Dist_Min_MMC>1

margins , at(ln_Dist_Min_MMC=(7.69 8.60)) post
outreg2 using Determinants_Lang_Probitmarg.tex,  stats(coef se ci) auto(2)  paren(se) bracket (ci)  append ctitle(Predicted prob.) addnote(NOTE: Shows the predicted probabilities at 25th and 75th percentile)


*****Table A9: Distance from sites of writing and association with other institutional measures


eststo clear
local outcome  socinf democ xconst 

foreach var of varlist `outcome' {


reg `var' ln_Dist_Min_MMC rootstuber_suitabilty cereal_suitabilty rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm  if sampledef==1 & ln_Dist_Min_MMC>1
eststo

}	 
esttab using "corr_dist_other", title("Determinants of Written Script before Contact with Christian Missionaries") ///
varwidth(32) replace booktabs  label ///
stats(r2 N,  labels ("R-squared" "Observations"))  scalars(r2 chi2 p ) ///
star (* 0.10 ** 0.05 *** 0.01) width(1.0\hsize)  


*****Table A10: Distance from sites of writing, linguistic diversity and language policy

eststo clear
local outcome LP_any_colonial LP_only_colonial LP_only_indigenous LP_any_indigenous  

foreach var of varlist `outcome' {


reg `var' ln_Dist_Min_MMC lnDistsites_lnnlang ln_lang  Npmispc23x10k japn_occupied_ww2  AsiaNew AmericaN rugged soil desert tropical dist_coast near_coast RiveraccessX100 areakm if sampledef==1 & ln_Dist_Min_MMC>1, robust
eststo

}	 
esttab using "Determinants_offlang_rform", title("Determinants of Written Script before Contact with Christian Missionaries") ///
varwidth(32) replace booktabs  label ///
stats(r2 N,  labels ("R-squared" "Observations"))  scalars(r2 chi2 p ) ///
star (* 0.10 ** 0.05 *** 0.01) width(1.0\hsize)  
*************************************************





